from django.urls import path, include
from rest_framework import routers
from rest_framework_jwt.views import obtain_jwt_token
from .views import TasksViewSet, user_logout, user_info, audit, task_exec, task_status, task_down, task_dashboard

# 注册ViewSet
router = routers.DefaultRouter()
router.register(r'tasks', TasksViewSet, basename='tasks')


urlpatterns = [
    path('', include(router.urls)),  # 注册viewset中的url
    path('api-token-auth/', obtain_jwt_token),  # jtw认证配置，用户前端过来的请求
    path('user/info/', user_info, name='user_info'),
    path('user/logout/', user_logout, name='user_logout'),
    path('audit/', audit, name='audit'),
    path('task_exec/<id>/', task_exec, name='task_exec'),
    path('task_status/<id>/', task_status, name='task_status'),
    path('task_down/<id>/', task_down, name='task_down'),
    path('task_dashboard/', task_dashboard, name='task_dashboard'),
]
